![]() | EncodeDataXML | Interacting with the Engine - Example | ![]() |
Knowledge Builder Web Applications can integrate with other applications in 3 ways:
ODBC Databases (@DBCall)
DOCX & RTF Documents (@Xrdoc)
XML Documents (@XMLdb)
URLfetch
XMLfetch & XMLpost
An alternative to the above server-side approach to integration, is to communicate directly between the Knowledge Builder app web pages and other web app's pages
Data can only be exchanged, provided both apps are hosted on the same domain. There are two ways in which this can be set up:
Knowledge Builder apps as the Container
Knowledge Builder apps embedded as an iframe on another app's Web page
3.1 Knowledge Builder Apps as the Container
This is where another app's url is embedded within a Knowledge Builder Dialog Object as "Web Page" control (iframe)
The following JavaScript sample code, when executed from a Knowledge Builder Dialog (e.g. via Macro Button), can exchange data with the embedded Web Page:
@Conditional JAVASCRIPT
var iframe = document.getElementById("control1");
var iframeDoc = iframe.contentWindow.document;
var iframeForm = iframeDoc.getElementById("myForm");
var retuned_value = iframeForm.fname.value;
SetValue(#MyStr, retuned_value);
@EndConditional
Note the following in the above code:
All the lines between @Conditional JAVASCRIPT and @EndConditional are standard JavaScript code.
control1 is the Name property value of the "Web Page" Control.
MyStr is the Knowledge Builder String Variable.
GetValue(#ObjectName) can be used to access the current value of any Knowledge Builder Object within by JavasScript.
Client-side integration will only work for a deployed app (i.e. not from the "Run" preview mode from within the Knowledge Builder developer).
3.2 Embedding the JavaScript Engine in a Web Page
The following is an example of a XpertRule JavaScript engine enabled web page:
Looking at the above page, you can see that embedding the engine into your own page can be extremely simple! Let's look at the elements in the above sample.
The above 2 lines are required to include the engine into the page.
The above line then includes the exported knowledge base.
Once the page has loaded, we call the Startup function with the id of the page element we wish to use for rendering the user interface. In this example, it's a div with an id of xrui. This is declared in the page as follows…
That's our simple example!!!